<template>
    <div>

        <div class="book_title">
            <h1 align="center">发布任务</h1>
        </div>

        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>系统中心</el-breadcrumb-item>
            <el-breadcrumb-item>发布任务</el-breadcrumb-item>
        </el-breadcrumb>
        <hr>
        <br>
        <el-form :model="replenishmentTask" ref="taskForm" label-width="80px">

            <el-form-item label="图书品类" prop="bookDetailedCode">
                <el-select v-model="replenishmentTask.bookDetailedCode" placeholder="请选择">
                    <el-option
                            v-for="item in bookDetailed"
                            :label="item.bookName"
                            :key="item.code"
                            :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="计划补货量" prop="planReplenishmentNum">
                <el-input v-model="replenishmentTask.planReplenishmentNum"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="addTask">确 定</el-button>
                <el-button type="info" @click="clearFrom">取 消</el-button>
            </el-form-item>
        </el-form>

    </div>
</template>

<script>
    export default {
        name: "editReplenishmentTask",
        data(){
            return{
                replenishmentTask:{
                    planReplenishmentNum:'',
                    bookDetailedCode:''
                },
                bookDetailed:[]
            }
        },
        methods:{
            addTask:function () {
                this.$http.post('/editReplenishmentTask?bookDetailedCode='+this.replenishmentTask.bookDetailedCode+'&planReplenishmentNum='+this.replenishmentTask.planReplenishmentNum).then((res)=>{
                    if(res.data.success){
                        this.$message.success(res.data.message)
                        this.$router.push("/getReplenishmentTask");
                    }else {
                        this.$message.error(res.data.message)
                    }
                })
            },
            clearFrom:function () {
                this.$refs['taskForm'].resetFields();
            },
            getBookDetailed:function () {
                this.$http.post('/book/findAllBookDetailed').then((res)=>{
                    if(res.data.success){
                        this.bookDetailed=res.data.result.bookDetailedList;
                    }
                })
            }
        },
        mounted() {
            this.getBookDetailed();
        }
    }
</script>

<style scoped>

</style>
